﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using BCDto.Tools;
using BCService.CRM.EnterpriseInfomation;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace BCTMSRESTful.Controllers.Anonymous
{
    [Route("api/v1/[controller]")]
    public class TestingController : BCTMSRESTfulAPIController
    {
        private readonly IEnterpriseInfomationService enterpriseInfomationService;

        public TestingController(IEnterpriseInfomationService enterpriseInfomationService)
        {
            this.enterpriseInfomationService = enterpriseInfomationService;
        }

        /// <summary>
        /// 测试导入企业信息excel数据。
        /// </summary>
        /// <response code="200">导入成功数量。</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(ImportResultDto), 200)]
        public IActionResult ImportEnterpriseExcel()
        {
            string path = Path.Combine(new DirectoryInfo(Directory.GetCurrentDirectory()).FullName, "123.xlsx");
            return this.Ok(this.enterpriseInfomationService.ImportEnterpriseFile("TianYanCha", path));
        }

    }
}
